<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;

class UserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, mixed>
     */
    public function rules()
    {
        return [
            'name'=>'required|between:3,100,regex:/^[A-Za-z0-9\-\_]+$/|unique:users,name,'.Auth::id(),
            'email'=>'required|email',
            'introduction'=>'max:200',
            'avatar'=>'mimes:png,jpeg,jpg,gif|dimensions:min_width:208,min_height=208'
        ];
    }

    public function attributes()
    {
        return [
          'name'=>'用户名',
          'email'=>'邮箱',
          'introduction'=>'简介',
          'avatar'=>'头像'
        ];
    }
}
